package com.guaoran.micro.services.spring.cloud.stream.rebbitmq.web.controller;

import com.guaoran.micro.services.spring.cloud.stream.rebbitmq.web.stream.producer.MessageProducerBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author : gucheng
 * @Description : <br/>
 * @date :2018/12/8 16:12
 */
@RestController
public class MessageProducerController {
    private final MessageProducerBean messageProducerBean;

    private final String topic;

    @Autowired
    public MessageProducerController(MessageProducerBean messageProducerBean,
                                     @Value("${rabbitMQ.topic}") String topic) {
        this.messageProducerBean = messageProducerBean;
        this.topic = topic;
    }

    /**
     * 通过{@link MessageProducerBean} 发送
     * @param message
     * @return
     */
    @GetMapping("/message/send")
    public Boolean send(@RequestParam String message) {
        messageProducerBean.send(message);
        return true;
    }

}
